#include "chapter13_practice3_dma.h"
#include <cstring>


	using namespace std;
	#include <iostream>
	//DmaABC_practice methods
	DmaABC_practice::DmaABC_practice(const char * l, int r)
	{
		label = new char[strlen(l) + 1];
		strcpy(label, l);
		rating = r;
	}

	DmaABC_practice::DmaABC_practice(const DmaABC_practice & dm)
	{
		label = new char[strlen(dm.label) + 1];
		strcpy(label, dm.label);
		rating = dm.rating;
	}

	DmaABC_practice::~DmaABC_practice()
	{
		delete[] label;
	}

	DmaABC_practice & DmaABC_practice::operator=(const DmaABC_practice & dm)
	{
		if (this == &dm)
			return *this;
		delete[] label;
		label = new char[strlen(dm.label) + 1];
		strcpy(label, dm.label);
		rating = dm.rating;
		return *this;
	}

	ostream & operator<<(ostream & os, const DmaABC_practice & dm)
	{
		os << "label: " << dm.label << endl;
		os << "Rating: " << dm.rating << endl;
		return os;
	}

	void DmaABC_practice::View() const
	{
		cout << "DmaABC_practice style: " << "label: " << label <<
			" ,Rating: " << rating << endl;
	}

	//baseDMA_practice methods
	baseDMA_practice::baseDMA_practice(const char * l, int r) :DmaABC_practice(l, r)
	{}

	ostream & operator<<(ostream & os, const baseDMA_practice & ba)
	{
		os << (const DmaABC_practice &)ba;
		return os;
	}

	void baseDMA_practice::View() const
	{
		cout << "baseDMA_practice style: " << "label: " << getLable() <<
			" ,Rating: " << getRating() << endl;
	}

	//lackDMA methods
	lacksDMA_practice::lacksDMA_practice(const char * c, const char * l, int r) :DmaABC_practice(l, r)
	{
		strncpy(color, c, 39);
		color[39] = '\0';
	}

	lacksDMA_practice::lacksDMA_practice(const char * c, const DmaABC_practice & dm) :DmaABC_practice(dm)
	{
		strncpy(color, c, 39);
		color[39] = '\0';
	}

	ostream & operator<<(ostream & os, const lacksDMA_practice & ls)
	{
		os << (const DmaABC_practice &)ls;
		os << "Color: " << ls.color << std::endl;
		return os;
	}

	void lacksDMA_practice::View() const
	{
		cout << "lacksDMA_practice style: " << "label: " << getLable() <<
			" ,Rating: " << getRating() << endl;
		cout << "Color: " << color << std::endl;
	}

	//hasDMA_practice methods
	hasDMA_practice::hasDMA_practice(const char *s, const char * l, const int r) :DmaABC_practice(l, r)
	{
		style = new char[strlen(s) + 1];
		strcpy(style, s);
	}

	hasDMA_practice::hasDMA_practice(const char * s, const DmaABC_practice & dm) :DmaABC_practice(dm)
	{
		style = new char[strlen(s) + 1];
		strcpy(style, s);
	}

	hasDMA_practice::~hasDMA_practice()
	{
		delete[] style;
	}

	hasDMA_practice::hasDMA_practice(const hasDMA_practice & hs) :DmaABC_practice(hs)
	{
		style = new char[strlen(hs.style) + 1];
		strcpy(style, hs.style);
	}

	hasDMA_practice & hasDMA_practice::operator=(const hasDMA_practice & ha)
	{
		if (this == &ha)
			return *this;
		DmaABC_practice::operator=(ha);
		delete[] style;
		style = new char[strlen(ha.style) + 1];
		strcpy(style, ha.style);
	}

	ostream & operator<<(ostream & os, const hasDMA_practice & ha)
	{
		os << (const DmaABC_practice &)ha;
		os << "style: " << ha.style << endl;
		return os;
	}

	void hasDMA_practice::View() const
	{
		cout << "lacksDMA_practice style: " << "label: "<< getLable() <<
			" ,Rating: " << getRating() << endl;
		cout << "Style: " << style << std::endl;
	}



